/*    */ package com.cr.framework.shiro.session;
/*    */ 
/*    */ import com.cr.common.utils.IpUtils;
/*    */ import com.cr.common.utils.ServletUtils;
/*    */ import eu.bitwalker.useragentutils.UserAgent;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import org.apache.shiro.session.Session;
/*    */ import org.apache.shiro.session.mgt.SessionContext;
/*    */ import org.apache.shiro.session.mgt.SessionFactory;
/*    */ import org.apache.shiro.web.session.mgt.WebSessionContext;
/*    */ import org.springframework.stereotype.Component;
/*    */ 
/*    */ @Component
/*    */ public class OnlineSessionFactory implements SessionFactory {
/*    */   public Session createSession(SessionContext initData) {
/* 24 */     OnlineSession session = new OnlineSession();
/* 25 */     if (initData != null && initData instanceof WebSessionContext) {
/* 27 */       WebSessionContext sessionContext = (WebSessionContext)initData;
/* 28 */       HttpServletRequest request = (HttpServletRequest)sessionContext.getServletRequest();
/* 29 */       if (request != null) {
/* 31 */         UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
/* 33 */         String os = userAgent.getOperatingSystem().getName();
/* 35 */         String browser = userAgent.getBrowser().getName();
/* 36 */         session.setHost(IpUtils.getIpAddr(request));
/* 37 */         session.setBrowser(browser);
/* 38 */         session.setOs(os);
/*    */       } 
/*    */     } 
/* 41 */     return (Session)session;
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-framework-4.7.0.jar!\com\cr\framework\shiro\session\OnlineSessionFactory.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */